package com.edu.ctgu;

import java.time.LocalDate;

public class YesterDate {
    public static String getPreviousDate(int year, int month, int day) {
        // 输入校验
        if (year < 1900 || year > 2050 || month < 1 || month > 12 || day < 1 || day > 31) {
            return "Invalid input";
        }

        // 使用 Java 的 LocalDate 类处理日期
        try {
            LocalDate date = LocalDate.of(year, month, day);
            LocalDate previousDate = date.minusDays(1);
            return previousDate.toString();
        } catch (Exception e) {
            return "Invalid input";
        }
    }
}
